﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tools.Domain.Validation;
using Web.App.Infrastructure.ApplicationMessages.Contracts;
using Tools.Domain.Specifications;
using Web.App.Infrastructure.ApplicationMessages.Implementation;

namespace Webshop20.Helper
{
    public class Mappings
    {


        private static IEnumerable<IInformation> GetInformations()
        {
            return new List<IInformation>();
        }

        private static IEnumerable<IWarning> GetWarnings()
        {
            return new List<IWarning>();
        }



        public static DomainMessage MapSpecificationErrorsToRuleFailures(IEnumerable<ISpecificationError> specificationErrors, string context, string action, string messageKey)
        {

            return new FailureMessage(GetFailures(specificationErrors),context, action, messageKey);


        }

        private static IEnumerable<IFailure> GetFailures(IEnumerable<ISpecificationError> errors)
        {
            foreach (var error in errors)
            {
                yield return new Failure(new object(), error.ErrorCode, string.Empty, string.Empty);
            }
        }
    }
}
